package datatypes;

import java.util.Vector;

public 	class RoutingObject {
	
	//Message Receiver 
	private BluetoothDeviceAddress target = null;
	//First Sender ()
	//Message that should be transmitted to target
	private Message message = null;
	//Route of BluetoothDevices (could be used for saving route or could be used for determine a route)
	//must be manipulated by the Routing Protocol itself, theres no automatic actualisation
	private Vector<BluetoothDeviceAddress> route = new Vector<BluetoothDeviceAddress>();
	//the type of a message is the explicit property of the Message
	//for example it can be used to compare with special "SEARCH PHRASE" etc.
	private String type = null;
	
	public Vector<BluetoothDeviceAddress> getRoute (){
		return this.route;
	}
	
	/**
	 * Konstruktor ohne Reason
	 * @param target --> finally Receiver
	 * @param msg
	 */
	public RoutingObject(BluetoothDeviceAddress target, Message msg){
		this.message = msg;
		this.target = target;
	}
	
	/**
	 * Konstruktor mit Reason
	 * @param target
	 * @param msg
	 * @param reason
	 */
	public RoutingObject(BluetoothDeviceAddress target, Message msg, String reason){
		this.message = msg;
		this.target = target;
		this.type = reason;
	}
	public void addHopToRoute (BluetoothDeviceAddress hop){
		this.route.add(hop);
	}
	
	public Message getMessage(){
		return this.message;
	}
	
	public Message getDiscoveryMessage (){
		if (this.message == null || this.message.isDiscoveryMessage()){
			return this.message;
		}
		return null;
	}

	public Message getRoutingMessage (){
		if (this.message == null || !this.message.isDiscoveryMessage()){
			return this.message;
		}
		return null;
	}

	public BluetoothDeviceAddress getTarget (){
		return this.target;
	}
	
	public BluetoothDeviceAddress getInitialSender(){
		return this.route.firstElement();
	}
	
	public String getType (){
		return this.type;
	}
	
	public void setRoute (Vector<BluetoothDeviceAddress> route){
		this.route = route;
	}
}
